//  学期 and 教学目标
class Term {
    School school
    String term//学期 上学期，下学期
    Integer year = Calendar.instance.get(Calendar.YEAR)
    Date startTime //开始时间
    Date endTime // 结束时间
    String description  // 教学目标

    static constraints = { 
        school( blank: false); 
        term(size: 0..50, blank: false)        
        startTime( blank: false)        
        endTime( blank: false)     
        year( blank: false)     
        description(blank: true, size:0..1000)
    }

    static mapping = {
       table 'xedu_term'
    }

    String toString() {
        "${year}年度${term}"
    }

    // 判断当前是什么学期
    static currentTerm(){
        def termZone = [[8,9,10,11,0,1],[2,3,4,5,6,7] ]
        def termContent = ['上学期','下学期']
        def month = Calendar.instance.get(Calendar.MONTH)
        return termZone[0].contains(month) ?termContent[0] : termContent[1]
    }
    static allTerm(){
        ['上学期','下学期'] 
    }
}
